package hcn.protocol.brandnew.zhenliao.jianyan;

import com.fasterxml.jackson.annotation.JsonFormat;
import ctd.util.xml.jaxb.DateAdapter;
import ctd.util.xml.jaxb.DateTimeAdapter;
import hcn.protocol.brandnew.BaseRequest;
import lombok.Data;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;
import org.atag.sysrouter.annotation.DictionaryMapping;

/**
 * 检验申请信息新增-请求消息 - ODS_03050010
 *
 * @author enjoyLife
 */
@Data
@XmlRootElement(name = "MsgBody")
@XmlAccessorType(XmlAccessType.FIELD)
public class LabRequestSubmitRequest extends BaseRequest {

    /**
     * 患者基本信息
     */
    @XmlElement(name = "Patient")
    private Patient patient;
    /**
     * 就诊摘要
     */
    @XmlElement(name = "Visit")
    private Visit visit;
    /**
     * 检验申请单
     */
    @XmlElement(name = "LabRequest")
    private LabRequest labRequest;

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Patient {

        /**
         * 业务系统患者档案ID
         */
        @XmlElement(name = "SourcePatientId")
        private String sourcePatientId;
        /**
         * 业务系统患者档案类型
         */
        @XmlElement(name = "SourcePatientIdType")
        private String sourcePatientIdType;
        /**
         * 建档机构代码
         */
        @XmlElement(name = "AuthorOrganization")
        private String authorOrganization;
        /**
         * 身份证件号码
         */
        @XmlElement(name = "IdCard")
        private String idCard;
        /**
         * 身份证件类别代码
         */
        @XmlElement(name = "IdCardCode")
        @DictionaryMapping(id = "CV02_01_101")
        private String idCardCode;
        /**
         * 患者姓名
         */
        @XmlElement(name = "Name")
        private String name;
        /**
         * 性别代码
         */
        @XmlElement(name = "Sex")
        private String sex;
        /**
         * 出生日期
         */
        @XmlElement(name = "BirthDate")
        @XmlJavaTypeAdapter(DateAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
        private Date birthDate;
        /**
         * 电话号码
         */
        @XmlElement(name = "PatientPhone")
        private String patientPhone;
        /**
         * 医保卡号
         */
        @XmlElement(name = "HealthInsuranceCardId")
        private String healthInsuranceCardId;
        /**
         * 地址
         */
        @XmlElement(name = "Address")
        private String address;
        /**
         * 病人性质
         */
        @XmlElement(name = "PatientProperties")
        private String patientProperties;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Visit {

        /**
         * 就诊流水号
         */
        @XmlElement(name = "VisitId")
        private String visitId;
        /**
         * 就诊机构代码
         */
        @XmlElement(name = "VisitOrganization")
        private String visitOrganization;
        /**
         * 患者类型代码
         */
        @XmlElement(name = "PatientType")
        @DictionaryMapping("CV09_00_404")
        private String patientType;
        /**
         * 就诊卡号
         */
        @XmlElement(name = "MedicalCardId")
        private String medicalCardId;
        /**
         * 就诊卡类别代码
         */
        @XmlElement(name = "MedicalCardType")
        private String medicalCardType;
        /**
         * 门（急）诊号
         */
        @XmlElement(name = "ClinicId")
        private String clinicId;
        /**
         * 住院号
         */
        @XmlElement(name = "HospizationId")
        private String hospizationId;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Diagnose {

        /**
         * 诊断类别代码
         */
        @XmlElement(name = "DiagnoseTypeCode")
        private String diagnoseTypeCode;
        /**
         * 诊断类别名称
         */
        @XmlElement(name = "DiagnoseTypeName")
        private String diagnoseTypeName;
        /**
         * 诊断日期时间
         */
        @XmlElement(name = "DiagnoseDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date diagnoseDateTime;
        /**
         * 疾病诊断编码
         */
        @XmlElement(name = "DiagnoseCode")
        private String diagnoseCode;
        /**
         * 疾病诊断名称
         */
        @XmlElement(name = "DiagnoseName")
        private String diagnoseName;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Childitem {

        /**
         * 医嘱项目明细记录流水号
         */
        @XmlElement(name = "OrderDetailId")
        private String orderDetailId;
        /**
         * 检验(明细)项目代码
         */
        @XmlElement(name = "ChildItemCode")
        private String childItemCode;
        /**
         * 检验(明细)项目名称
         */
        @XmlElement(name = "ChildItemName")
        private String childItemName;
        /**
         * 收费项目代码
         */
        @XmlElement(name = "CostID")
        private String costID;
        /**
         * 收费项目名称
         */
        @XmlElement(name = "CostName")
        private String costName;
        /**
         * 费用单价
         */
        @XmlElement(name = "CostPrice")
        private String costPrice;
        /**
         * 费用数量
         */
        @XmlElement(name = "CostNumber")
        private String costNumber;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Item {

        /**
         * 检验标本号
         */
        @XmlElement(name = "SampleNo")
        private String sampleNo;
        /**
         * 检验项目代码
         */
        @XmlElement(name = "ItemCode")
        private String itemCode;
        /**
         * 检验项目名称
         */
        @XmlElement(name = "ItemName")
        private String itemName;
        /**
         * 标本类别代码
         */
        @XmlElement(name = "SampleTypeCode")
        private String sampleTypeCode;
        /**
         * 标本类别名称
         */
        @XmlElement(name = "SampleTypeName")
        private String sampleTypeName;
        /**
         * 项目单价
         */
        @XmlElement(name = "ItemPrice")
        private String itemPrice;
        /**
         * 项目数量
         */
        @XmlElement(name = "ItemCount")
        private String itemCount;
        /**
         * 项目费用
         */
        @XmlElement(name = "ItemCost")
        private String itemCost;
        /**
         * 计费标志
         */
        @XmlElement(name = "FeeStatus")
        private Boolean feeStatus;
        /**
         * (门诊)发票号码
         */
        @XmlElement(name = "InvoiceNo")
        private String invoiceNo;
        /**
         * 医师医嘱流水号
         */
        @XmlElement(name = "OrderId")
        private String orderId;
        /**
         * 执行日期时间
         */
        @XmlElement(name = "ExamExecuteTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date examExecuteTime;
        /**
         * 执行科室代码
         */
        @XmlElement(name = "ExamExecuteDept")
        private String examExecuteDept;
        /**
         * 执行科室名称
         */
        @XmlElement(name = "ExamExecuteDeptName")
        private String examExecuteDeptName;
        /**
         * 执行机构
         */
        @XmlElement(name = "ExamExecuteOrg")
        private String examExecuteOrg;
        /**
         * 检验方法代码
         */
        @XmlElement(name = "ExamMethodCode")
        private String examMethodCode;
        /**
         * 检验方法名称
         */
        @XmlElement(name = "ExamMethodName")
        private String examMethodName;
        /**
         * 注意事项
         */
        @XmlElement(name = "RequestNote")
        private String requestNote;
        /**
         * 检验费用类别
         */
        @XmlElement(name = "Feetype")
        private Byte feetype;
        /**
         * 免费标识
         */
        @XmlElement(name = "CostFreeSign")
        private Byte costFreeSign;
        /**
         * 项目明细集合
         */
        @XmlElementWrapper(name = "Childitems")
        @XmlElement(name = "Childitem")
        private List<Childitem> childitems;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class LabRequest {

        /**
         * 检验申请单编号
         */
        @XmlElement(name = "RequestId")
        private String requestId;
        /**
         * 婴儿判别
         */
        @XmlElement(name = "IsNeonatus")
        private Boolean isNeonatus;
        /**
         * 年龄（岁）
         */
        @XmlElement(name = "Age")
        private Short age;
        /**
         * 年龄（月）
         */
        @XmlElement(name = "MonthAge")
        private String monthAge;
        /**
         * 科室代码
         */
        @XmlElement(name = "Dept")
        private String dept;
        /**
         * 科室名称
         */
        @XmlElement(name = "DeptName")
        private String deptName;
        /**
         * 病区代码
         */
        @XmlElement(name = "WardArea")
        private String wardArea;
        /**
         * 病区名称
         */
        @XmlElement(name = "WardAreaName")
        private String wardAreaName;
        /**
         * 病床号
         */
        @XmlElement(name = "SickbedId")
        private String sickbedId;
        /**
         * 病房号
         */
        @XmlElement(name = "SickRoomId")
        private String sickRoomId;
        /**
         * 病床编码
         */
        @XmlElement(name = "SickbedNo")
        private String sickbedNo;
        /**
         * 病房编号
         */
        @XmlElement(name = "SickRoomNo")
        private String sickRoomNo;
        /**
         * 申请单描述
         */
        @XmlElement(name = "RequestDesc")
        private String requestDesc;
        /**
         * 申请单状态
         */
        @XmlElement(name = "RequestStatus")
        private Byte requestStatus;
        /**
         * 审核日期时间
         */
        @XmlElement(name = "RequestCheckTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date requestCheckTime;
        /**
         * 审核医师代码
         */
        @XmlElement(name = "RequestCheckerId")
        private String requestCheckerId;
        /**
         * 审核医师姓名
         */
        @XmlElement(name = "RequestCheckerName")
        private String requestCheckerName;
        /**
         * 紧急标志
         */
        @XmlElement(name = "IsEmergency")
        private Boolean isEmergency;
        /**
         * 申请时间
         */
        @XmlElement(name = "RequestDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date requestDateTime;
        /**
         * 申请医师代码
         */
        @XmlElement(name = "RequestDoctor")
        private String requestDoctor;
        /**
         * 申请医生姓名
         */
        @XmlElement(name = "RequestDoctorName")
        private String requestDoctorName;
        /**
         * 申请科室代码
         */
        @XmlElement(name = "RequestDept")
        private String requestDept;
        /**
         * 申请科室名称
         */
        @XmlElement(name = "RequestDeptName")
        private String requestDeptName;
        /**
         * 申请项目全称
         */
        @XmlElement(name = "ExamText")
        private String examText;
        /**
         * 申请执行机构
         */
        @XmlElement(name = "ExamExecuteOrg")
        private String examExecuteOrg;
        /**
         * 申请执行科室
         */
        @XmlElement(name = "ExamExecuteDept")
        private String examExecuteDept;
        /**
         * 审核日期时间
         */
        @XmlElement(name = "AuditDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date auditDateTime;
        /**
         * 审核医师代码
         */
        @XmlElement(name = "AuditDoctorCode")
        private String auditDoctorCode;
        /**
         * 审核医师姓名
         */
        @XmlElement(name = "AuditDoctorName")
        private String auditDoctorName;
        /**
         * 申请单有效开始时间
         */
        @XmlElement(name = "EffectiveTimeLow")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date effectiveTimeLow;
        /**
         * 申请单有效结束时间
         */
        @XmlElement(name = "EffectiveTimeHigh")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date effectiveTimeHigh;
        /**
         * 优先级别代码
         */
        @XmlElement(name = "PriorityCode")
        private String priorityCode;
        /**
         * 优先级别名称
         */
        @XmlElement(name = "PriorityName")
        private String priorityName;
        /**
         * 备注
         */
        @XmlElement(name = "RemarkInfo")
        private String remarkInfo;
        /**
         * 注意事项
         */
        @XmlElement(name = "AnesthesiaAttentionProblem")
        private String anesthesiaAttentionProblem;
        /**
         * 诊断节点
         */
        @XmlElementWrapper(name = "Diagnoses")
        @XmlElement(name = "Diagnose")
        private List<Diagnose> diagnoses;
        /**
         * 申请项目集合
         */
        @XmlElementWrapper(name = "Items")
        @XmlElement(name = "Item")
        private List<Item> items;
    }

}
